#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    int t=sqrt(n);
    if(t*t<n)t++;
    int grid[t+105][t+105];
    //memset(grid,0,sizeof grid);
    int cnt=0;
    for(int i=0;i<t;i++){
        for(int j=0;j<t;j++){
            grid[i][j]=++cnt;
            if(cnt==n)goto awa;
        }
    }
    awa:;
    vector<pair<int,int>> frog,bird;
    for(int i=0;i<t;i++){
        for(int j=0;j<t-1;j++){
            if(grid[i][j+1]<=0) break;
            frog.push_back({grid[i][j],grid[i][j+1]});
        }
    }
    for(int j=0;j<t;j++){
        for(int i=0;i<t-1;i++){
            if(grid[i+1][j]==0)break;
            bird.push_back({grid[i][j],grid[i+1][j]});
        }
    }
    int m=min(frog.size(),bird.size());
    cout<<m<<'\n';
    for(int i=0;i<m;i++){
        cout<<frog[i].first<<' '<<frog[i].second<<'\n';
    }
    for(int i=0;i<m;i++){
        cout<<bird[i].first<<' '<<bird[i].second<<'\n';
    }
    return 0;
}